var Donate = {
	validateForm:function(fundID){
		var form = jQuery('form#donationForm_'+fundID);
		var amount = form.find('input[name=amount]').val() || "";
		if(amount == ""){
			System.showValidation("Amount is required");
			return false;
		} else if(!System.isUser()){
			return false;
		} else {
			return true;
		}
	},
	
	donate:function(fundID){
		if(Donate.validateForm(fundID)){
			var fundrow = jQuery('div#meter_wrap_'+fundID);
			var args = fundrow.find('form#donationForm_'+fundID).serialize();
			jQuery.ajax({
				url:"/cfcs/remote.cfc?cfc=donationService&method=run&callMethod=saveDonation&userID="+jQuery('input#userID').val()+"&"+args,
				type:"GET",
				success:function(data){
					System.expandedFund = -1;
					System.reloadFundRow(fundID, 'donate');
				}
			});
		}
	}
};

jQuery(document).ready(function(){
	Validate.activate(jQuery('form#donationForm'));
});
